package com.yunxi.controller.otd;

import com.yunxi.otd.pojo.OtdOrderCirWeekVersionQueryVO;
import com.yunxi.otd.pojo.OtdOrderMonthVersionChangeStateVO;
import com.yunxi.otd.pojo.OtdOrderMonthVersionVO;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.yunxi.core.web.ResponseUtil;
import com.yunxi.core.web.CurrentUser;
import com.yunxi.core.web.ApiResult;
import com.yunxi.core.web.LoginInfo;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import com.yunxi.otd.service.OtdOrderCirWeekVersionDubboService;
import com.yunxi.otd.pojo.OtdOrderCirWeekVersionVO;

/**
 * <p>
 * 周CIR预测版本管理 前端控制器
 * </p>
 *
 * @author XUQI
 * @since 2019-10-14
 */
@RestController
@RequestMapping("/admin/week/version")
@Api(tags = "OTD:WEEKVERSION", description = "周CIR预测版本管理接口")
public class OtdOrderCirWeekVersionController {

    private static final Logger logger = LoggerFactory.getLogger(OtdOrderCirWeekVersionController.class);

    @Autowired
    OtdOrderCirWeekVersionDubboService otdOrderCirWeekVersionDubboService;

    @GetMapping("/page")
    @ApiOperation(value = "查询周CIR预测版本管理分页")
    public ApiResult page(OtdOrderCirWeekVersionQueryVO queryVO, Integer pageNum, Integer pageSize) throws Exception {
        return ResponseUtil.ok(otdOrderCirWeekVersionDubboService.findPageByVO(queryVO, pageNum, pageSize));
    }

    @GetMapping("/enable")
    @ApiOperation(value = "下拉框查询")
    public ApiResult enable() {
        OtdOrderCirWeekVersionVO otdOrderMonthVersionVO = new OtdOrderCirWeekVersionVO();
        otdOrderMonthVersionVO.setState("1");
        return ResponseUtil.ok(otdOrderCirWeekVersionDubboService.listByVo(otdOrderMonthVersionVO));
    }

    @PostMapping("/change")
    @ApiOperation(value = "状态变更")
    public ApiResult change(@RequestBody OtdOrderCirWeekVersionVO vo) {
        return otdOrderCirWeekVersionDubboService.changeState(vo);
    }

    @PostMapping("/remove")
    @ApiOperation(value = "删除版本")
    public ApiResult remove(@RequestBody List<String> ids) {
        return otdOrderCirWeekVersionDubboService.removeByIds(ids);
    }

    @PostMapping("/default")
    @ApiOperation(value = "设置默认版本")
    public ApiResult setDefault(@RequestBody Map<String, Object> map) {
        String id = (String) map.get("id");
        if (StringUtils.isEmpty(id)) {
            return ResponseUtil.fail(-1, "参数错误，ID不能为空！");
        }
        return otdOrderCirWeekVersionDubboService.setDefault((String) map.get("id"));
    }

    /*@PostMapping("/export")
    @ApiOperation(value = "导出excel")
    public Object export(@RequestParam Map<String, Object> params) throws Exception {
        return ResponseUtil.ok(otdOrderCirWeekVersionDubboService.findMapByList(params));
    }*/
}
